<tagLib name="html" />
<script language="javascript" src="/Public/static/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<div id="main-content">
    <div id="main" class="main">
        <!-- 修改密码 start -->
        <div class="spin-cont">
            <div class="user-hd">
                <h2>代理商管理>>{$page_title}</h2>
            </div>
            <div class="user_zl">
                <form name="data_form" id="data_form" method="POST">
                <dl class="clearfix">
                    <dt>代理商合同号：</dt>
                    <dd>
                        <input type="text" id="agent_contract_no" name="agent_contract_no" value="{$info.agent_contract_no}" placeholder="请输入15位以内的数字、字母或者下划线" autocomplete="off" maxlength="18" class="bg-input w229"/>
                    </dd>
                    <dd class="error_message" id="message_agent_contract_no"></dd>
                </dl>				
                <dl class="clearfix">
                    <dt>代理商名称：</dt>
                    <dd>
                        <input type="text" id="agent_name" name="agent_name" value="{$info.agent_name}" placeholder="请输入15位以内的汉字" autocomplete="off" maxlength="18" class="bg-input w229"/>
                    </dd>
                    <dd class="error_message" id="message_agent_name"></dd>
                </dl>
                <dl class="clearfix">
                    <dt>代理商有效期：</dt>
					<dd><input type="text" name="agent_starttime" id="create_time_start" value="{$info.agent_starttime|date='Y-m-d',###}" class="Wdate bg-input mr5" onFocus="WdatePicker({maxDate:'#F{ $dp.$D(\'create_time_end\')||\'2020-10-01\'}'})" readonly="readonly" size="30" style="width: 90px;" /></dd>
					<dd><input type="text" name="agent_endtime" id="create_time_end" value="{$info.agent_endtime|date='Y-m-d',###}" class="Wdate bg-input mr5" onFocus="WdatePicker({minDate:'#F{ $dp.$D(\'create_time_start\')}',maxDate:'2020-10-01'})" readonly="readonly" size="30" style="width: 90px;" /></dd>
					<dd class="error_message" id="message_time"></dd>
				</dl>
                <dl class="clearfix">
                    <dt>代理商保证金：</dt>
                    <dd>
                        <input type="text" id="agent_deposit" name="agent_deposit" value="{$info.agent_deposit}" placeholder="请输入最大为1000000的数字" autocomplete="off" maxlength="18" class="bg-input w229"/>
                    </dd>
					<dd>元</dd>
                    <dd class="error_message" id="message_agent_deposit"></dd>
                </dl>
                <dl class="clearfix">
                    <dt>代理商佣金比例：</dt>
                    <dd>
                        <input type="text" id="agent_brokerage" name="agent_brokerage"  value="{$info.agent_brokerage}" placeholder="请输入佣金比例" autocomplete="off" maxlength="18" class="bg-input w229"/>
                    </dd>
					<dd>百分比</dd>
                    <dd class="error_message" id="message_agent_brokerage"></dd>
                </dl>
                <dl class="clearfix">
                    <dt>代理商合同：</dt>
					<dd><input type="text" name="agent_contract" value="{$info.agent_contract}" id="agent_contract"  readonly="readonly" /></dd>
                    <dd style="margin-top:10px;">
                        <input type="file" name="upload" id="upload" autocomplete="off" maxlength="18" class="bg-input w229"/>
                    </dd>
                    <dd class="error_message" id="message_agent_contract"></dd>
                </dl>				
                <dl class="clearfix">
                    <dt>代理商计费价格：</dt>
                    <dd>
                        <input type="text" id="agent_price" name="agent_price" value="{$info.agent_price}" placeholder="请输入最大为10000的数字" autocomplete="off" maxlength="18" class="bg-input w229"/>
                    </dd>
					<dd>元/间-月</dd>
                    <dd class="error_message" id="message_agent_price"></dd>
                </dl>
                <dl class="clearfix">
                    <dt>联系电话：</dt>
                    <dd>
                        <input type="text" id="agent_tel" name="agent_tel" value="{$info.agent_tel}" placeholder="请输入11位手机号码" autocomplete="off" maxlength="18" class="bg-input w229"/>
                    </dd>
                    <dd class="error_message" id="message_agent_tel"></dd>
                </dl>				
                <dl class="clearfix">
                    <dt>联系地址：</dt>
                    <dd>
                        {:w('Area/multLevel', array(1, '', 1, $info[area_1], $info[area_2], $info[area_3]))}
                    </dd>
					<dd class="error_message" id="message_area"></dd>
                </dl>
                <dl class="clearfix">
                    <dt>&nbsp;</dt>
                    <dd><input type="text" id="address" name="address" value="{$info.address}" placeholder="请输入地址，最长40个字" autocomplete="off" class="bg-input w229"/></dd>
                    <dd class="error_message" id="message_address"></dd>
                </dl>
				
                <dl class="clearfix">
                    <dt>联系人：</dt>
                    <dd><input type="text" id="agent_contacts" name="agent_contacts" value="{$info.agent_contacts}" placeholder="最长15位以内的中文、英文" autocomplete="off" class="bg-input w229"/></dd>
                    <dd class="error_message" id="message_agent_contacts"></dd>
                </dl>
                <dl class="clearfix">
                    <dt>公司全称：</dt>
                    <dd><input type="text" id="agent_company_name" name="agent_company_name" value="{$info.agent_company_name}" placeholder="最长20位以内的中文、英文" autocomplete="off" class="bg-input w229"/></dd>
                    <dd class="error_message" id="message_agent_company_name"></dd>
                </dl>
                <dl class="clearfix">
                    <dt>法人代表：</dt>
                    <dd><input type="text" id="agent_legal_person" name="agent_legal_person" value="{$info.agent_legal_person}" placeholder="最长15位以内的中文、英文" autocomplete="off" class="bg-input w229"/></dd>
                    <dd class="error_message" id="message_agent_legal_person"></dd>
                </dl>
                <dl class="clearfix">
                    <dt>身份证件：</dt>
                    <dd><input type="text" id="agent_identity" name="agent_identity" value="{$info.agent_identity}" placeholder="请输入15或18位身份证号码" autocomplete="off" class="bg-input w229"/></dd>
                    <dd class="error_message" id="message_agent_identity"></dd>
                </dl>
				<dl class="clearfix">
                    <dt>2016计费方式：</dt>
                    <dd>
                        <html:select options="billing_video_play_type" name="billing_video_play_type" id="billing_video_play_type" selected="info[billing_video_play_type]" />
                    </dd>
                </dl>
                <dl class="clearfix">
                    <dt>企业资质：</dt>
                        <dd style="margin-top:10px; margin-bottom:10px;">
                            <link rel="stylesheet" href="__PUBLIC__/admin/css/upload.css">
                            <div class="speechbox_add">
                                <div class="uploadBox">
                                    <for start="0" end="3">
                                        <input type="hidden" name="images[]" id="u{$i}_input" value="{$info['agent_honor'][$i]}" class="bg-input w229"/>
                                        <div class="upload_area">
                                            <div class="uImg uImg1" id="u{$i}_divhide"  style="display: <empty name='info[agent_honor][$i]' >block<else />none</empty>;">
                                                <span class="op"><input type="file" class="inputFile" id="u{$i}_placeholder_0" value="{$info['agent_honor'][$i]}" /></span>
                                            </div>
                                            <div class="uImg uImg1" id="u{$i}_divshow" style="display: <empty name='info[agent_honor][$i]' >none<else />block</empty>;">
                                                <img src="{:getThumb($info['agent_honor'][$i], '212x295')}" />
                                            <span class="op_2">
                                                <input type="file" class="inputFile" id="u{$i}_placeholder_1" /> | <a href="javascript:void(0)" onclick="deleteUpload('u{$i}')">删除照片</a>
                                            </span>
                                            </div>
                                        </div>
                                    </for>
                                </div>
                            </div>
                        </dd>		
                    <dd class="error_message" id="message_agent_honor"></dd>
                </dl>
                <dl class="clearfix">
                    <dt>备注：</dt>
					<dd><textarea id="agent_mark" name="agent_mark" class="bg-textarea w229"  placeholder="请输入1-100个字符">{$info.agent_mark}</textarea></dd> 
					<dd class="error_message" id="message_agent_mark"></dd>
                </dl>
				<dl class="clearfix">
                    <dt>授权凭证上传：</dt>
                    <dd style="width:239px;">
                        <div class="speechbox_add">
                            <div class="uploadBox">
                                <input type="hidden" name="auth_pic" id="u9_input" value="{$info.auth_pic}" class="bg-input w229"/>
                                <div class="upload_area">
                                    <div class="uImg uImg1" id="u9_divhide" <if condition="'' EQ $info[auth_pic]">style="display: block;"<else/>style="display: none;"</if>>
                                        <span class="op"><input type="file" class="inputFile" id="u9_placeholder_0" /></span>
                                    </div>
                                    <div class="uImg uImg1" id="u9_divshow" <if condition="'' NEQ $info[auth_pic]">style="display: block;"<else/>style="display: none;"</if>>
                                        <img src="{$info.auth_pic}" />
                                    <span class="op_2">
                                        <input type="file" class="inputFile" id="u9_placeholder_1" /> | <a href="javascript:void(0)" onclick="deleteUpload('u9')">删除照片</a>
                                    </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </dd>
                    <dd class="error_message" id="message_img_url"></dd>
                </dl>
                <dl class="clearfix">
                    <dt>授权凭证码：</dt>
                    <dd>
                        <input type="text" id="auth_code_1" name="auth_code_1" value="{$info.auth_code_1}" maxlength="36" autocomplete="off" class="bg-input"/>
                        <input type="text" id="auth_code_2" name="auth_code_2" value="{$info.auth_code_2}" maxlength="36" autocomplete="off" class="bg-input w229"/>
                    </dd>
                    <dd class="error_message" id="message_auth_code"></dd>
                </dl>
                <dl class="clearfix">
                    <dt></dt>
                    <dd>
                        <a href="javascript:;" class="gray-btn" onclick="postClick()">确定</a>
                        <a href="javascript:;" class="gray-btn" onclick="reset('data_form')">取消</a>
						<input type="hidden" id="id" name="id" value="{$info.id}" autocomplete="off" class="bg-input w229"/>
                    </dd>
                </dl>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
	$(function() {
		$("#upload").uploadify({
			height        : 22,
			fileObjName   : "upload",
			buttonText    : "上传合同",
			swf           : '/Public/static/uploadify/uploadify.swf',
			uploader      : "{:U('Admin/File/uploadFile')}",
			width         : 80,
			fileTypeExts	  : '*.doc; *.docx; *.docx; *.jpeg; *.jpg',
			onUploadSuccess : function(file, data, response) {
									var obj = eval("("+data+")");
									if(obj.status == 0){
										alert(obj.info);
									}else{
										$('#agent_contract').val(obj.url);
									}
									//alert(data);
								},
			
		});
	});
</script>

<script type="text/javascript">
    function postClick(){
        //判断授权凭证码是否重复
        var auth_code_1=$('#auth_code_1').val();
        var auth_code_2=$('#auth_code_2').val();
        if(auth_code_1=='' && auth_code_2!=''){
            $('#message_auth_code').html('授权凭证码不完整');
            $('#auth_code_1').focus();
            return false;
        }
        if(auth_code_1!='' && auth_code_2==''){
            $('#message_auth_code').html('授权凭证码不完整');
            $('#auth_code_2').focus();
            return false;
        }
        if(auth_code_1!="" && auth_code_2!=''){
            $.get("{:U('Admin/Cinema/checkAuthInfo')}",{auth_code_1:auth_code_1,auth_code_2:auth_code_2,id:"{:I('get.id')}"},function(result){
                if(result.status_code===1){
                    $('#message_auth_code').html('授权凭证码重复，请重新输入');
                    $('#auth_code_1').focus();
                    return false;
                }else{
                    $('#message_auth_code').html('');
                    saveAgentAdd();
                }
            })
        }else{
            $('#message_auth_code').html('');
            saveAgentAdd();
        }
    }

function saveAgentAdd(){
	//代理商合同号
	var agent_contract_no = $('#agent_contract_no').val();
	var reg = /^[a-z\d]{1,15}$/i;  
	if(reg.test(agent_contract_no) === false){
		$('#message_agent_contract_no').html("请输入15位以内的数字、字母或者下划线");
		return false;
	}else{
		$('#message_agent_contract_no').html("");
	}
	//代理商名称
	var agent_name = $('#agent_name').val();
	if(agent_name.length<1 || agent_name.length>30){
		$('#message_agent_name').html("请输入15位以内的汉字");
		return false;
	}else{
		$('#message_agent_name').html("");
	}
	//代理商有效期
	var agent_starttime = $('#create_time_start').val();
	var agent_endtime = $('#create_time_end').val();
	if(agent_starttime.length<1 || agent_endtime.length<1){
		$('#message_time').html("必填");
		return false;
	}else{
		$('#message_time').html("");
	}		
	//代理商保证金
	var agent_deposit = $('#agent_deposit').val();
	var reg = /^[\d]{1,7}$/i;  
	if(reg.test(agent_deposit) === false ||　agent_deposit>1000000){
		$('#message_agent_deposit').html("请输入最大为1000000的数字");
		return false;
	}else{
		$('#message_agent_deposit').html("");
	}
	//代理商佣金比例
	var agent_brokerage = $('#agent_brokerage').val();
	var reg = /^[0-9]+([.][0-9]{1}){0,1}$/;  
	if(agent_brokerage<0 || agent_brokerage>100 || reg.test(agent_brokerage) === false){
		$('#message_agent_brokerage').html("请输入佣金比例(0-100之间的数字)");
		return false;
	}else{
		$('#message_agent_brokerage').html("");
	}
	//代理商计费价格
	var agent_price = $('#agent_price').val();
	var reg = /^[\d]{1,5}$/i;  
	if(reg.test(agent_price) === false ||agent_price>10000){
		$('#message_agent_price').html("请输入最大为10000的数字");
		return false;
	}else{
		$('#message_agent_price').html("");
	}
	//联系电话
	var agent_tel = $('#agent_tel').val();
	var reg = /^1[3|4|5|8|7][0-9]\d{4,8}$/;  
	if(reg.test(agent_tel) === false){
		$('#message_agent_tel').html("请输入11位手机号码");
		return false;
	}else{
		$('#message_agent_tel').html("");
	}
	//联系地址
	var area1 = $("#mutil_level_data_1_id_1").val();
	var area2 = $("#mutil_level_data_1_id_2").val();
	var area3 = $("#mutil_level_data_1_id_3").val();
	if(area1 == ''){
		$('#message_area').html("请选择地区");
		return false;
	}else{
		$('#message_area').html("");
	}
	if(area2 == ''){
		$('#message_area').html("请选择地区");
		return false;
	}else{
		$('#message_area').html("");
	}
	if(area3 == ''){
		$('#message_area').html("请选择地区");
		return false;
	}else{
		$('#message_area').html("");
	}	
	var address = $('#address').val();
	if(address.length<1 || address.length>80){
		$('#message_address').html("请输入地址，最长40个字");
		return false;
	}else{
		$('#message_address').html("");
	}
	//联系人
	var agent_contacts = $('#agent_contacts').val();
	if(agent_contacts.length<1 || agent_contacts.length>15){
		$('#message_agent_contacts').html("最长15位以内的中文、英文");
		return false;
	}else{
		$('#message_agent_contacts').html("");
	}
	//公司全称
	var agent_company_name = $('#agent_company_name').val();
	if(agent_company_name.length<1 || agent_company_name.length>40){
		$('#message_agent_company_name').html("最长20位以内的中文、英文");
		return false;
	}else{
		$('#message_agent_company_name').html("");
	}
	//法人代表
	var agent_legal_person = $('#agent_legal_person').val();
	if(agent_legal_person.length<1 || agent_legal_person.length>15){
		$('#message_agent_legal_person').html("最长15位以内的中文、英文");
		return false;
	}else{
		$('#message_agent_legal_person').html("");
	}
	//身份证件
	var agent_identity = $('#agent_identity').val();
	var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;  
	if(reg.test(agent_identity) === false){
		$('#message_agent_identity').html("请输入15或18位身份证号码");
		return false;
	}else{
		$('#message_agent_identity').html("");
	}	
	//备注
	var agent_mark = $('#agent_mark').val();
	if(agent_mark.length>=100){
		$('#message_agent_mark').html("请输入1-100个字符");
		return false;
	}else{
		$('#message_agent_mark').html("");
	}

	$.ajax({
		url:"{:U('Admin/Agent/update')}",
		type:"post",
		data:$('form').serialize(),
		success:function(data,status,xhr){
				if (data.status==1) {
					alertMessage(data.info + ' 页面即将自动跳转~', 1, 2);
					if (data.url) {
						delayGoToPage(data.url, 2000);
					}
				}else{
					alertMessage(data.info, '', 2);
				}
		},
	});
}


</script>

<script src="/Public/static/uploadify/jquery.uploadify.min.js"></script>
<style>
    .speechbox_add .upload_area .uImg1 .op{width: 200px;height: 200px}
    .speechbox_add .upload_area .uImg1 {width: 200px;height: 200px}
    .speechbox_add .upload_area .uImg1 img {width: 200px;height: 200px; display: block;}
    .speechbox_add .upload_area {width: 200px; height: 200px;}
</style>
<script language="javascript">
    var buttonsize_b = {"width":200,"height":200};
    var buttonsize_s = {"width":55,"height":19};
    //初始化
    specialUpload('u0_placeholder_0',buttonsize_b,'u0',false);
    specialUpload('u0_placeholder_1',buttonsize_s,'u0',true);
    specialUpload('u1_placeholder_0',buttonsize_b,'u1',false);
    specialUpload('u1_placeholder_1',buttonsize_s,'u1',true);
    specialUpload('u2_placeholder_0',buttonsize_b,'u2',false);
    specialUpload('u2_placeholder_1',buttonsize_s,'u2',true);
	specialUpload('u9_placeholder_0',buttonsize_b,'u9',false);
    specialUpload('u9_placeholder_1',buttonsize_s,'u9',true);

    function specialUpload(id,buttonsize,keyname,showtext){
        var textValue = (showtext) ? '重新上传' : '';
        var  swfu = new SWFUpload({
            upload_url:"{:U('/Admin/Common/upload',array('type'=>'hall'))}",
            file_types : "*.png;*.jpg;*.jpeg;*.bmp;",
            file_dialog_complete_handler : function(numFilesSelected, numFilesQueued) {
                try {
                    if (numFilesQueued > 0) {
                        this.startUpload();
                    }
                } catch (ex) {
                    alertMessage(ex);
                }
            },
            //选择文件的前置操作
            file_dialog_start_handler : function(){},
            //选择的文件
            file_queued_handler : function(file){},

            //选择不合规范的文件
            file_queue_error_handler : function(file, errCode, errMsg){
                if(errCode == -110){
                    alertMessage('请选择不超过 5M的图片!');
                }
                if(errCode == -120){
                    alertMessage('传个0尺寸的图片忽悠谁呢!');
                }
            },
            //上传成功
            upload_success_handler : function(file, serverData) {
                var data = jQuery.parseJSON(serverData);
                if(data.status == 1){
                    $("#"+keyname + '_input').val(data.url);
                    $("#"+keyname+'_divhide').hide();
                    $("#"+keyname+'_divshow').show();
                    $("#"+keyname+'_divshow').find('img').attr("src",data.url);
                } else {
                    alertMessage(data.info);
                }
            },
            button_placeholder_id : id,
            button_text:textValue,
            file_size_limit:5*1024,
            button_width: buttonsize.width,
            button_height: buttonsize.height,
            button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
            button_cursor: SWFUpload.CURSOR.HAND,
            flash_url : "/Public/static/uploadify/uploadify.swf"
        });
    }
    //删除上传图片
    function deleteUpload(keyname){
        $("#"+keyname+'_divshow').find('img').attr('src','');
        $("#"+keyname+'_divshow').hide();
        $("#"+keyname+'_divhide').show();
        $("#"+keyname+'_input').val('');
    }
</script>
<script language="javascript">
    is_add = {$is_add};
</script>